<template>
  <div>
    <van-nav-bar
      title="支付页面"
      left-text="返回"
      nav-bar-text-color="@white"
      left-arrow
      @click-left="onClickLeft"
    />
    <div class="main">
      <h5 class="row0">订单号:{{ $route.query.orderCode }}</h5>
      <h2 class="row0">&yen;{{ $route.query.countmoney }}</h2>
      <p class="row0 p">请选择支付方式</p>
      <van-radio-group v-model="radio" style="display: flex; flex-wrap: wrap">
        <div class="row clearfix">
          <div class="l fl">支付宝支付</div>
          <div class="r fr">
            <van-radio name="1" @change="radio = '1'"></van-radio>
          </div>
        </div>
        <div class="row clearfix">
          <div class="l fl">微信支付</div>
          <div class="r fr">
            <van-radio name="2" @change="radio = '2'"></van-radio>
          </div>
        </div>
      </van-radio-group>
      <van-button
        @click="toPay"
        type="info"
        style="
          position: absolute;
          bottom: 0;
          left: 50%;
          transform: translate(-50%, 0);
          width: 3.3rem;
          border-radius: 0.3rem;
        "
        >确定支付</van-button
      >
    </div>
  </div>
</template>

<script>
import { pay } from "../../request/api";
export default {
  data() {
    return {
      radio: 1,
    };
  },
  methods: {
    onClickLeft() {
      this.$toast.success("返回到上一级");
      this.$router.back();
    },
    toPay() {
      let data = {
        outTradeNo: Number(this.$route.query.orderCode),
        totalAmount: Number(this.$route.query.countmoney),
        type: 1,
      };
      console.log(data);
      pay(data).then((res) => {
        console.log(res);
        if (res.code === 200) {
          this.$toast.success("支付成功");
          this.$router.push("/index")
        } else {
          this.$toast.success("网络中断");
        }
      });
    },
  },
  mounted() {
    console.log(this.$route.query.countmoney);
     document.title=this.$route.meta.title
  },
};
</script>

<style scoped>
/* * 顶部返回字体样式  */
/deep/.van-nav-bar {
  background: #ff6040;
}
/deep/ .van-nav-bar__title {
  font-size: 0.18rem;
  font-weight: bold;
  color: #fff;
}
/deep/ .van-nav-bar__text {
  font-size: 0.12rem;
  color: #fff;
}
/deep/ .van-nav-bar .van-icon {
  font-size: 0.12rem;
  color: #fff;
}

/deep/ [class*="van-hairline"]::after {
  border: none;
}
/deep/ .van-nav-bar__content {
  height: 49px;
}
.main {
  position: relative;
  padding-top: 0.3rem;
}
h2,
h5 {
  text-align: center;
}
.main h2 {
  margin-bottom: 0.3rem;
}
.row0 {
  width: 3.55rem;
  margin: 0 auto;
  height: 0.3rem;
}
.row {
  width: 3.55rem;
  margin: 0 auto;
  height: 0.3rem;
  /* display: flex;
  justify-content: space-between; */
}
</style>